/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.For;
import org.xtext.example.cr.cR.Forall;
import org.xtext.example.cr.cR.Print;
import org.xtext.example.cr.cR.StandardFunction;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Standard Function</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.StandardFunctionImpl#getPrint <em>Print</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.StandardFunctionImpl#getFor <em>For</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.StandardFunctionImpl#getForall <em>Forall</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StandardFunctionImpl extends MinimalEObjectImpl.Container implements StandardFunction
{
  /**
   * The cached value of the '{@link #getPrint() <em>Print</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPrint()
   * @generated
   * @ordered
   */
  protected Print print;

  /**
   * The cached value of the '{@link #getFor() <em>For</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFor()
   * @generated
   * @ordered
   */
  protected For for_;

  /**
   * The cached value of the '{@link #getForall() <em>Forall</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getForall()
   * @generated
   * @ordered
   */
  protected Forall forall;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected StandardFunctionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.STANDARD_FUNCTION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Print getPrint()
  {
    return print;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetPrint(Print newPrint, NotificationChain msgs)
  {
    Print oldPrint = print;
    print = newPrint;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.STANDARD_FUNCTION__PRINT, oldPrint, newPrint);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPrint(Print newPrint)
  {
    if (newPrint != print)
    {
      NotificationChain msgs = null;
      if (print != null)
        msgs = ((InternalEObject)print).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.STANDARD_FUNCTION__PRINT, null, msgs);
      if (newPrint != null)
        msgs = ((InternalEObject)newPrint).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.STANDARD_FUNCTION__PRINT, null, msgs);
      msgs = basicSetPrint(newPrint, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.STANDARD_FUNCTION__PRINT, newPrint, newPrint));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public For getFor()
  {
    return for_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetFor(For newFor, NotificationChain msgs)
  {
    For oldFor = for_;
    for_ = newFor;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.STANDARD_FUNCTION__FOR, oldFor, newFor);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFor(For newFor)
  {
    if (newFor != for_)
    {
      NotificationChain msgs = null;
      if (for_ != null)
        msgs = ((InternalEObject)for_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.STANDARD_FUNCTION__FOR, null, msgs);
      if (newFor != null)
        msgs = ((InternalEObject)newFor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.STANDARD_FUNCTION__FOR, null, msgs);
      msgs = basicSetFor(newFor, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.STANDARD_FUNCTION__FOR, newFor, newFor));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Forall getForall()
  {
    return forall;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetForall(Forall newForall, NotificationChain msgs)
  {
    Forall oldForall = forall;
    forall = newForall;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.STANDARD_FUNCTION__FORALL, oldForall, newForall);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setForall(Forall newForall)
  {
    if (newForall != forall)
    {
      NotificationChain msgs = null;
      if (forall != null)
        msgs = ((InternalEObject)forall).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.STANDARD_FUNCTION__FORALL, null, msgs);
      if (newForall != null)
        msgs = ((InternalEObject)newForall).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.STANDARD_FUNCTION__FORALL, null, msgs);
      msgs = basicSetForall(newForall, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.STANDARD_FUNCTION__FORALL, newForall, newForall));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.STANDARD_FUNCTION__PRINT:
        return basicSetPrint(null, msgs);
      case CRPackage.STANDARD_FUNCTION__FOR:
        return basicSetFor(null, msgs);
      case CRPackage.STANDARD_FUNCTION__FORALL:
        return basicSetForall(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.STANDARD_FUNCTION__PRINT:
        return getPrint();
      case CRPackage.STANDARD_FUNCTION__FOR:
        return getFor();
      case CRPackage.STANDARD_FUNCTION__FORALL:
        return getForall();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.STANDARD_FUNCTION__PRINT:
        setPrint((Print)newValue);
        return;
      case CRPackage.STANDARD_FUNCTION__FOR:
        setFor((For)newValue);
        return;
      case CRPackage.STANDARD_FUNCTION__FORALL:
        setForall((Forall)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.STANDARD_FUNCTION__PRINT:
        setPrint((Print)null);
        return;
      case CRPackage.STANDARD_FUNCTION__FOR:
        setFor((For)null);
        return;
      case CRPackage.STANDARD_FUNCTION__FORALL:
        setForall((Forall)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.STANDARD_FUNCTION__PRINT:
        return print != null;
      case CRPackage.STANDARD_FUNCTION__FOR:
        return for_ != null;
      case CRPackage.STANDARD_FUNCTION__FORALL:
        return forall != null;
    }
    return super.eIsSet(featureID);
  }

} //StandardFunctionImpl
